package com.mdd.front.controller;

import com.mdd.common.core.AjaxResult;
import com.mdd.common.entity.team.Team;
import com.mdd.front.LikeFrontThreadLocal;
import com.mdd.front.service.ITeamService;
import com.mdd.front.validate.team.TeamAuthValicate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/team")
@Api(tags = "社团信息")
public class TeamController {

    @Resource
    ITeamService iTeamService;

    @PostMapping("/admin/apply")
    @ApiOperation(value="社团管理员认证申请")
    public AjaxResult adminApply(@Validated @RequestBody TeamAuthValicate valicate){
        Integer userId = LikeFrontThreadLocal.getUserId();
        valicate.setOwnerId(userId);
        iTeamService.adminApply(valicate);
        return AjaxResult.success();
    }

    @GetMapping("/detail")
    @ApiOperation(value="文章详情")
    public AjaxResult<Team> detail() {
        Integer userId = LikeFrontThreadLocal.getUserId();
        Team vo = iTeamService.detail(userId);
        return AjaxResult.success(vo);
    }
}
